//
//  ListViewCell.m
//  MyClouds
//
//  Created by sarah doo on 13-8-7.
//  Copyright (c) 2013年 sarah doo. All rights reserved.
//

#import "ListViewCell.h"

@interface ListViewCell()

@property (nonatomic, retain)UILabel *deviceLabel;

@property (nonatomic, retain)UILabel *addressLabel;

@end

@implementation ListViewCell

@synthesize model, deviceLabel, addressLabel;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        [self createViews];
    }
    return self;
}

- (void)createViews {
    UIView *view = [[UIView alloc] initWithFrame:self.contentView.frame];
    UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(10, 5, 60, 65)];
    imageView.image = [UIImage imageNamed:@"02.png"];
    [view addSubview:imageView];
    [imageView release];
    
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(80, 5, view.frame.size.width - 90, 35)];
    label.backgroundColor = [UIColor clearColor];
    label.textColor  = [UIColor greenColor];
    self.deviceLabel = label;
    [view addSubview:label];
    [label release];
    
    label = [[UILabel alloc] initWithFrame:CGRectMake(80, 45, view.frame.size.width - 90, 35)];
    label.backgroundColor = [UIColor clearColor];
    label.textColor  = [UIColor blackColor];
    self.addressLabel = label;
    [view addSubview:label];
    [label release];
    [self.contentView addSubview:view];
    [view release];
}

- (void)setModel:(ListViewModel *)_model {
    if (model != _model) {
        [model release];
        model = [_model retain];
    }
    self.deviceLabel.text = model.deviceName;
    self.addressLabel.text = model.IPAddress;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)dealloc {
    self.model = nil;
    self.addressLabel = nil;
    self.deviceLabel = nil;
    [super dealloc];
}

@end
